package unit04.day01;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

/**
 * 复制文件
 * @author cola
 *
 */
public class CopyDemo1 {

	public static void main(String[] args) throws IOException {
		RandomAccessFile src = new RandomAccessFile("music.mp3","r");
		RandomAccessFile dest = new RandomAccessFile("music_cp1.mp3","rw");
		int d = -1;
		long start = System.currentTimeMillis();
		while((d=src.read()) != -1) {
			dest.write(d);
		}
		long end = System.currentTimeMillis();
		System.out.println("复制完毕，耗时:"+(end-start));
		src.close();
		dest.close();
	}

}
